$(document).ready(function(){
    $('a[href*=comentar]').hide();

    $('#ComentarioComentario').maxlength({
        //events: [], // Array of events to be triggerd
        maxCharacters: 1024, // Characters limit
        status: true, // True to show status indicator bewlow the element
        statusClass: "status", // The class on the status div
        statusText: "caracteres restantes", // The status text
        notificationClass: "notification",	// Will be added when maxlength is reached
        showAlert: false, // True to show a regular alert message
        alertText: "You have typed too many characters.", // Text in alert message
        slider: false // True Use counter slider
    });

    $('#ComentarioValidaForm').validate({
        rules: {
                'data[Comentario][nome]': {
                        required: true
                },
                'data[Comentario][email]': {
                        required: true,
                        email: true
                },
                'data[Comentario][site]': {
                        required: false,
                        url: true
                },
                'data[Comentario][comentario]':{
                        required: true
                }
        },
        messages: {
                'data[Comentario][nome]': 'Preencha seu nome',
                'data[Comentario][email]': {
                        required: 'Preencha com um e-mail válido',
                        email: 'E-mail inválido! Preencha com um e-mail válido'
                },
                'data[Comentario][site]': {
                        url: 'Endereço inválido!'
                },
                'data[Comentario][comentario]': 'Faltou seu comentário!'
        }
    });

    $('#ComentarioSite').change(function(){
        if(!($(this).val().substring(0,7) == 'http://'))
            $(this).val('http://' + $(this).val());
    });

    /*$('#comentario').dialog({
        autoOpen: false,
        modal: true
        //buttons: {
        //    'Cancelar': function(){ $(this).dialog('close'); }
        //}
    });

    $('#EnviarComentario').click(function(){
       $('#comentario').dialog('open');
    });*/
});